package com.huadao.cart_ccs.modle;

import com.huadao.cart_ccs.base.BaseSerialPortModel;
import com.huadao.cart_ccs.common.ByteUtils;
import com.huadao.cart_ccs.data.bo.CommandWord;
import com.huadao.cart_ccs.data.bo.CultureTankBO;
import com.huadao.cart_ccs.data.bo.Protocol;

/**
 * 培养罐电机
 */
public class CultureTankModle extends BaseSerialPortModel {

    private String TAG="培养罐电机";

    public void openMagneticStirrer(int speed){
//        Logger.i(TAG,"打开"+" 转速："+speed);
        byte[] speedByte= ByteUtils.int2bytesLG(1,speed);
        setMagneticStirrer(CultureTankBO.star,speedByte);
    }

    public void closeMagneticStirrer(){
//        Logger.i(TAG,"停止");
        setMagneticStirrer(CultureTankBO.stop,null);
    }

    private void setMagneticStirrer(byte order,byte[] speed){
        byte[] orderContent;
        if(order== CultureTankBO.star) {//启动
            orderContent = speed;
        }else {//停止
            orderContent = new byte[]{00};
        }
        Protocol params = ByteUtils.generateProtocol(CommandWord.write, new byte[]{CultureTankBO.ModularType_VacuumPump, CultureTankBO.VacuumPump_cultureTank,order}, orderContent);
        serialPortRequest(params);
    }
}
